<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>expend</title>
    <link rel="stylesheet" href="../..//lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <form class="layui-form" action="" style="padding:20px;">
            <div style="text-align: center;margin: 10px 10px 20px 30px;line-height: 50px">
                <label class="layui-row" id="balance" style="font-family: 'Agency FB'; font-size: 20px; color: #000000">医院余额:</label>
            </div>
        </form>
        <div class="layui-form-item">
            <label class="layui-form-label">type:</label>
            <div class="layui-input-inline">
                <div class="layui-form" lay-filter="myDiv">
                    <select name="" id="type" lay-filter="mySelect">
                        <option value="医保">医保</option>
                        <option value="药品">药品</option>
                        <option value="设备">设备</option>
                    </select>
                </div>
            </div>
            <div class="layui-input-inline">
                <button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-bbb"><i
                        class="layui-icon"></i> 搜 索
                </button>
            </div>
        </div>
        <div class="layui-btn-container">
            <button class="layui-btn layui-btn-sm data-add-btn"> 创建缴费单</button>
            <button class="layui-btn layui-btn-sm layui-btn-danger data-update-btn"> 添加支出</button>
        </div>
        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>


    </div>
</div>

<script src="../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="../../js/lay-config.js?v=1.0.4" charset="utf-8"></script>

<script>
    layui.use(['table', 'form'], function () {
        //开始使用

        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            layuimini = layui.layuimini;

        $.ajax({
            url: "http://localhost:8080/dyx_doctor/allMoney",    //请求的url地址
            dataType: "json",   //返回格式为json
            async: true,//请求是否异步，默认为异步，这也是ajax重要特性
            data: {"id": "value"},    //参数值
            type: "GET",   //请求方式
            beforeSend: function () {
                //请求前的处理
            },
            success: function (res) {
                $('#balance').html("医院总余额 :" + res.data);
            },
            complete: function () {
                //请求完成的处理
            },
            error: function () {
                //请求出错处理
            }
        });

        var userInfo = layui.data('userInfo');

        //展示所有expend
        table.render({
            elem: '#currentTableId',
            url: 'http://localhost:8080/dyx_doctor/allExpend',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            cols: [[
                {field: 'expendid', width: 80, title: 'ID', sort: true},
                {field: 'type', width: 200, title: '支出类型'},
                {field: 'information', width: 200, title: '支出信息'},
                {field: 'expendmoney', width: 200, title: '支出金额'},
                {field: 'expendtime', width: 200, title: '支出时间'}
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 20,
            page: true
        });

        // 监听搜索操作
        form.on('submit(data-search-bbb)', function (data) {
            var field = data.field;

            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    type: $('#type').val(),
                }//这里传参  向后台
                , url: 'http://localhost:8080/dyx_doctor/findExpendByType'
                , method: 'get'
            }, 'data');

            return false;
        });

        // 监听添加操作
        $(".data-add-btn").on("click", function () {

            var index = layer.open({
                title: '添加缴费单',
                type: 2,
                shade: 0.2,
                maxmin: true,
                shadeClose: true,
                area: ['100%', '100%'],
                content: './operation/add_payment.html',
            });
            $(window).on("resize", function () {
                layer.full(index);
            });

            return false;
        });

        $(".data-update-btn").on("click", function () {

            var index = layer.open({
                title: '添加支出',
                type: 2,
                shade: 0.2,
                maxmin: true,
                shadeClose: true,
                area: ['100%', '100%'],
                content: './operation/add_device.html',
            });
            $(window).on("resize", function () {
                layer.full(index);
            });

            return false;
        });
    });
</script>
</body>
</html>